package com.example.entity.vo;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class ResponseData {

    private int code;  // 状态码 0 为正常  1 失败
    private String msg;
    private Object data;
    private long count;

    public static ResponseData ok(String msg) {
        return ResponseData.builder().code(0).msg(msg).build();
    }

    public static ResponseData data(Object data) {
        return ResponseData.builder().code(0).data(data).build();
    }

    public static ResponseData data(String msg, Object data) {
        return ResponseData.builder().code(0).msg(msg).data(data).build();
    }

    public static ResponseData page(long count, Object data) {
        return ResponseData.builder().code(0).count(count).data(data).build();
    }

    public static ResponseData fail(String msg) {
        return ResponseData.builder().code(1).msg(msg).build();
    }

}
